package father

import (
	"chatgpt/helper"
	"chatgpt/helper/code"
	"chatgpt/model/app"
	"github.com/gin-gonic/gin"
)

func UserRegisterCheck(ctx *gin.Context, user *app.User) code.CODENO {
	if mcode := helper.LoginAccount.LengthCheck(user.Passwd); mcode != code.SUCCESS {
		return mcode
	}

	if RawString(ctx, "PasswdRepeat") != user.Passwd {
		return code.REQ_PASSWD_TWICE_ERR
	}
	user.Passwd = helper.LoginAccount.AccountPassword(user.Passwd)
	return code.SUCCESS
}
